
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>下载参数配置</title>
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/Common.js"></script>
    <link rel="stylesheet" type="text/css" href="css/web.css" />
    <link rel="stylesheet" href="css/Common.css" />
    <script type="text/javascript">
        $(function () {
            var leftOffset = ($(window).width() - $(".pop-form").width()) / 2;
            var topOffset = ($(window).height() - $(".pop-form").height()) / 2 - 50;
            $(".pop-form").css("left", leftOffset);
            $(".pop-form").css("top", topOffset);
            $(".pop-close").click(function () {
                closeForm();
            });
        });


        //编辑保存
        function editSave() {
            if ($("input[name='ThreadCount']").val().trim() != "" && !isNaN($("input[name='ThreadCount']").val())) {
                if ($("input[name='ThreadCount']").val() <= 999) {
                    if ($("input[name='RequestLength']").val().trim() != "" && !isNaN($("input[name='RequestLength']").val())) {
                        if ($("input[name='WriteLength']").val().trim() != "" && !isNaN($("input[name='WriteLength']").val())) {
                            $.post("/AutoUpdate/DownParametersSave", { urlParameters: $("#form-parameter-edit").serialize() }, function (result) {
                                if (result.ResultCode == "SUCCESS") {
                                    $(".pop-message span").text(result.Message);
                                    setTimeout(function () {
                                        window.location.reload();
                                    }, 700);
                                }
                                else {
                                    $(".pop-message span").text(result.Message);
                                }
                            }, "JSON");
                        }
                        else {
                            $(".pop-message span").text("不正确的写入块大小！");
                            $("input[name='WriteLength']").val("").focus();
                        }
                    }
                    else {
                        $(".pop-message span").text("不正确的请求块大小！");
                        $("input[name='RequestLength']").val("").focus();
                    }
                }
                else {
                    $(".pop-message span").text("最大线程数为999！");
                    $("input[name='ThreadCount']").focus();
                }
            }
            else {
                $(".pop-message span").text("不正确的线程数！");
                $("input[name='ThreadCount']").val("").focus();
            }
        }

        //编辑
        function editRecord(id) {
            $("#reset").removeAttr("onclick");
            displayForm('parameter-edit');
            $.post("/AutoUpdate/DownParameterEdit", { parameterId: id }, function (result) {
                if (result.ResultCode == "SUCCESS") {
                    $("input[name='ParameterId']").val(result.Result.ParameterId);
                    if (result.Result.ApplicationType == '0') {
                        $("select[name='ApplicationType']").val(0);
                    }
                    else if (result.Result.ApplicationType == '1') {
                        $("select[name='ApplicationType']").val(1);
                    }
                    else if (result.Result.ApplicationType == '2') {
                        $("select[name='ApplicationType']").val(2);
                    }
                    $("input[name='ThreadCount']").val(result.Result.ThreadCount);
                    $("input[name='RequestLength']").val(result.Result.RequestLength / 1024);
                    $("input[name='WriteLength']").val(result.Result.WriteLength / 1024);
                    $("input[name='GCCount']").val(result.Result.GCCount);
                }
                else {
                    $(".pop-message span").text(result.Message);
                }
            }, "JSON");
        }

        //显示弹出层
        function displayForm(formId) {
            if (formId != null) {
                $(".blacklayer").css("display", "block");
                $("#" + formId + "").fadeIn(100);
                $(".pop-table input:first").focus();
            }
        }

        //关闭弹出层
        function closeForm() {
            $(".blacklayer").hide();
            $(".pop-form").fadeOut(100);
            resetForm();
            resetMessage();
        }

        //重置表单
        function resetForm() {
            $(".pop-table input").val("");
            $("#reset").attr("onclick", "resetForm(); resetMessage();");
        }
        //重置消息
        function resetMessage() {
            $(".pop-message span").text("");
        }
    </script>
</head>
<body>

    <div class="con-all">
        
        <div class="con-header">
            
            <div class="con-header-left">
                <div style="background-color: #E74C5E;width:15px; float:left; height:40px;"></div>
                <div style="text-align:left; color:black; font-size:11pt; ">
                    &nbsp;首页&nbsp;>&nbsp;自动升级&nbsp;>&nbsp;下载参数配置
                </div>
            </div>
            
            <div class="con-header-right">
                <a class="custom-btn" style="float:right;" onclick="displayForm('parameter-edit');" href="javascript:;">添加</a>
            </div>
        </div>
        
        <div class="con-content">
            
            <table class="con-tb">
                <tr>
                    <th>终端类型</th>
                    <th>线程数</th>
                    <th>请求块大小（KB）</th>
                    <th>写入块大小（KB）</th>
                    
                    <th colspan="2">操作</th>
                </tr>
                        <tr>
                                <td>安卓终端</td>
                            <td>3</td>
                            <td>1024</td>
                            <td>1024</td>
                            
                            <td style="width:50px;">
                                <span><a class="con-tb-img-edit" title="编辑" href="javascript:;" onclick="editRecord('2a2ef091-6af8-4a79-ab26-f28ddff1f5c3');"></a></span>
                            </td>
                            <td style="width:50px;">
                                <span><a class="con-tb-img-delete" title="删除" href="javascript:;" onclick="DeleteRecord('2a2ef091-6af8-4a79-ab26-f28ddff1f5c3');"></a></span>
                            </td>
                        </tr>
                        <tr>
                                <td>车载终端</td>
                            <td>2</td>
                            <td>1024</td>
                            <td>1024</td>
                            
                            <td style="width:50px;">
                                <span><a class="con-tb-img-edit" title="编辑" href="javascript:;" onclick="editRecord('7c066ed5-0092-45ba-90a1-5c5605155148');"></a></span>
                            </td>
                            <td style="width:50px;">
                                <span><a class="con-tb-img-delete" title="删除" href="javascript:;" onclick="DeleteRecord('7c066ed5-0092-45ba-90a1-5c5605155148');"></a></span>
                            </td>
                        </tr>
                        <tr>
                                <td>医院终端</td>
                            <td>3</td>
                            <td>1024</td>
                            <td>1024</td>
                            
                            <td style="width:50px;">
                                <span><a class="con-tb-img-edit" title="编辑" href="javascript:;" onclick="editRecord('148b103a-0057-4fbe-9ddb-055617af50e5');"></a></span>
                            </td>
                            <td style="width:50px;">
                                <span><a class="con-tb-img-delete" title="删除" href="javascript:;" onclick="DeleteRecord('148b103a-0057-4fbe-9ddb-055617af50e5');"></a></span>
                            </td>
                        </tr>
                        <tr>
                                <td>车载终端</td>
                            <td>2</td>
                            <td>2048</td>
                            <td>1024</td>
                            
                            <td style="width:50px;">
                                <span><a class="con-tb-img-edit" title="编辑" href="javascript:;" onclick="editRecord('3a6e9abd-9b8f-4429-897e-dc46375320a3');"></a></span>
                            </td>
                            <td style="width:50px;">
                                <span><a class="con-tb-img-delete" title="删除" href="javascript:;" onclick="DeleteRecord('3a6e9abd-9b8f-4429-897e-dc46375320a3');"></a></span>
                            </td>
                        </tr>
                        <tr>
                                <td>医院终端</td>
                            <td>3</td>
                            <td>2048</td>
                            <td>2048</td>
                            
                            <td style="width:50px;">
                                <span><a class="con-tb-img-edit" title="编辑" href="javascript:;" onclick="editRecord('1cbe9033-c7cf-4eab-9ccc-436629ca0cd7');"></a></span>
                            </td>
                            <td style="width:50px;">
                                <span><a class="con-tb-img-delete" title="删除" href="javascript:;" onclick="DeleteRecord('1cbe9033-c7cf-4eab-9ccc-436629ca0cd7');"></a></span>
                            </td>
                        </tr>
            </table>
            
            
        </div>
    </div>
    
<div class="blacklayer">
</div>
<div class="poplayer">
    <div class="tit">
        <span><!--标题文字--></span>
        <div class="close">X</div>
    </div>
    <div class="con">
        <div class="message">
            <!--内容区-->
        </div>
        <div class="dbutton">
            <a id="cancel" class="btn" href="javascript:;">取消</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <a id="confirm" class="btn" href="javascript:;">确定</a>
        </div>
    </div>
</div>

    
    <div id="parameter-edit" class="pop-form">
        <div class="pop-title">
            <span>下载参数编辑</span>
            <div title="关闭" class="pop-close">X</div>
        </div>
        <div class="pop-content">
            
            <form id="form-parameter-edit">
                <input name="ParameterId" type="hidden" value="" />
                <table class="pop-table">
                    <tr>
                        <td style="text-align:right; padding-right:10px; width:100px;">终端类型</td>
                        <td>
                            <select name="ApplicationType" class="text-select">
                                <option value="0">医院终端</option>
                                <option value="1">车载终端</option>
                                <option value="2">安卓终端</option>
                            </select>
                        </td>
                        <td style="text-align: right; padding-right: 10px; width: 100px;">线程数</td>
                        <td>
                            <input name="ThreadCount" class="text-input" type="text" maxlength="128" value="" placeholder="线程数" />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; padding-right: 10px;">请求块大小</td>
                        <td>
                            <input name="RequestLength" class="text-input" type="text" maxlength="10" value="" placeholder="请求块大小（KB）" />
                        </td>
                        <td style="text-align: right; padding-right: 10px;">写入块大小</td>
                        <td>
                            <input name="WriteLength" class="text-input" type="text" maxlength="10" value="" placeholder="写入块大小（KB）" />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right; padding-right: 10px;">GC间隔阈值</td>
                        <td>
                            <input name="GCCount" class="text-input" type="text" value="1000" readonly="readonly" placeholder="累计请求次数" maxlength="5" />
                        </td>
                    </tr>
                    <tr>
                        <td class="pop-message" colspan="4" style="text-align:center;color:red; height:30px; line-height:30px;"><span></span></td>
                    </tr>
                </table>
            </form>
            <div class="button-area">
                <div class="button-left">
                    <a id="reset" title="重置" class="custom-btn" onclick="resetForm(); resetMessage();" style="float: right; margin-right:10px; " href="javascript:;">重置</a>
                </div>
                <div class="button-right">
                    <a id="save" title="保存" class="custom-btn" onclick="editSave();" style="float: left; margin-left:10px;" href="javascript:;">保存</a>
                </div>
            </div>
        </div>
    </div>


    <style>
        .td-table {
            width: 100%;
            margin: 0px 0px 10px 0px;
            padding: 0px;
            border-collapse: collapse;
            border: 0px;
        }

            .td-table tr {
                width: 100%;
                height: auto;
                margin: 0px;
                padding: 0px;
            }

                .td-table tr td {
                    width: auto;
                    height: 25px;
                    line-height: 25px;
                    border: 0px;
                    font-size: 12pt;
                }

        /*弹出表单层样式*/
        .pop-form {
            width: 750px;
            height: auto;
            position: fixed;
            box-sizing: border-box;
            border: solid 1px #E74C5E;
            background-color: white;
            z-index: 20000;
            display: none;
        }

        .pop-title {
            width: 748px;
            height: 35px;
            line-height: 35px;
            margin: 0px;
            padding: 0px;
            float: left;
            background-color: #E74C5E;
            color: white;
            box-sizing: border-box;
            padding-left: 10px;
        }

        .pop-close {
            text-align: center;
            float: right;
            width: 35px;
            height: 35px;
            /*background-color: #E74C5E;*/
        }

            .pop-close:hover {
                cursor: pointer;
                background-color: #eb6676;
            }

        .pop-content {
            width: 748px;
            height: auto;
            float: left;
            padding-bottom: 20px;
        }

        .pop-table {
            border: 0px;
            padding: 0px;
            margin-top: 20px;
            box-sizing: border-box;
            border: 0px;
            border-collapse: collapse;
            width: 100%;
        }

            .pop-table tr {
                width: 100%;
                height: 50px;
                margin: 0px;
                padding: 0px;
                line-height: 50px;
            }

                .pop-table tr td {
                    /*border: solid 1px black;*/
                }

        .button-area {
            width: 100%;
            height: 50px;
            float: left;
        }

        .button-left {
            width: 50%;
            float: left;
            padding: 5px;
            box-sizing: border-box;
        }

        .button-right {
            width: 50%;
            float: right;
            padding: 5px;
            box-sizing: border-box;
        }

        .text-input {
            width: 230px;
            height: 30px;
            line-height: 20px;
            padding: 5px;
        }

        .text-select {
            width: 244px;
            height: 43px;
            line-height: 33px;
            padding: 5px;
        }

        .role-edit {
            width: 100%;
            height: auto;
            /*border: solid 1px #CCC;*/
            box-sizing: border-box;
        }

            .role-edit ul {
                margin: 10px 0px 10px 0px;
                padding: 0px;
                border: 0px;
                list-style: none;
            }

                .role-edit ul li {
                    width: 166px;
                    height: 30px;
                    text-align: left;
                    /*line-height: 30px;*/
                    padding-left: 10px;
                    box-sizing: border-box;
                    float: left;
                }
    </style>
</body>
</html>


<script type="text/javascript">

    //删除一条记录
    function DeleteRecord(id) {
        ShowBox({ Content: "确定要删除这条记录吗？" }, function () {
            $.post("/AutoUpdate/DeleteDownParameter", { parameterId: id }, function (result) {
                ShowBox({ Content: result.Message });
                if (result.ResultCode == "SUCCESS") {
                    setTimeout(function () {
                        window.location.reload();
                    }, 600);
                }
            });
        });
    }
</script>
